#![no_std]
#![no_main]
#![feature(abi_x86_interrupt)]

mod interrupts;
mod mem_io;
mod serial;
mod spinlock;
mod vga;
use core::arch::asm;
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn _start() -> ! {
    vga::init(); // 初始化VGA
    serial::init(); // 初始化串口
    interrupts::init(); // 初始化中断描述符表

    println!("Hello Rust OS!");
    println!("System initialized");
    unsafe {
        asm!("int 0x8");
    };
    loop {}
}

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
    println!("{}", info);
    loop {}
}

#[no_mangle]
#[link_section = ".multiboot_header"]
pub static MULTIBOOT2_HEADER: [u32; 8] = [
    0xe85250d6,                                                         // Multiboot2 magic
    0,     // Architecture (0 = i386, 3 = x86_64)
    8 * 4, // Header length
    (0xe85250d6u32.wrapping_add(0).wrapping_add(8 * 4)).wrapping_neg(), // Checksum
    // End tag
    0,
    0,
    8,
    0,
];
